﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TransFormer.Web.admin
{
    public partial class UserInfoEdit : AdminPage
    {
        private BLL.UserInfo _bll = new BLL.UserInfo();
        private Model.UserInfo model;
        protected void Page_Load(object sender, EventArgs e)
        {
            var idStr = Request["Id"];
            int id;
            if (int.TryParse(idStr, out id))
            {
                model = _bll.GetModel(id);
                if (!IsPostBack)
                {
                    txtUserName.Text = model.UserName;
                    txtDesc.Text = model.UserDesc;
                    txtPwd.Text = model.Pwd;
                }
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {

            model.UserName = txtUserName.Text;
            model.UserDesc = txtDesc.Text;
            model.Pwd = txtPwd.Text;
            _bll.Update(model);
            Response.Redirect("main.aspx");
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("main.aspx");
        }
    }
}